<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>聊天测试</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="js/json2.js"></script>
<script src="js/socket.io/socket.io.js"></script>
<script src="js/moment.min.js"></script>
<script type="text/javascript">

var userName = 'user' + Math.floor((Math.random() * 1000) + 1);
var socket =  io.connect('http://localhost:9527');

socket.on('connect', function() {
			alert('<span class="connect-msg">Client has connected to the server!</span>');
});

socket.on('chatevent', function(data) {
	alert('<span class="username-msg">' + data.userName + ':</span> ' + data.message);
});

socket.on('disconnect', function() {
	alert('<span class="disconnect-msg">The client has disconnected!</span>');
});


 var jsonObject = {username: userName,
				  rank:'111',
				  roomId:'2222'};
  socket.emit('joinRoom', jsonObject);

  var jsonObject = {
			userName: '322323',
			msgContent: '343443'
		};
		socket.emit('message', jsonObject);
    </script>
</head>
<body>
	
</body>
</html>